package www.openteam.com.model.PrdctnMngmnt;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import www.openteam.com.base.BaseModel;
import www.openteam.com.bean.SendRcvBean;
import www.openteam.com.transformer.ErrorTransformer;

/**
 * Created by OT on 2017-10-20.
 */

public class SendRcvModel extends BaseModel {

    public void getSendRcvData(String stype, String rdsno, final SendDataListener sendDataListener){
        httpApiService.getRcvSendData(stype,rdsno)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<SendRcvBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        sendDataListener.fail(e);
                    }

                    @Override
                    public void onNext(SendRcvBean sendRcvBean) {
                        sendDataListener.success(sendRcvBean);
                    }
                })
                ;
    }

    public interface SendDataListener{
        void success(SendRcvBean sendRcvBean);

        void fail(Throwable e);
    }
}
